package functors;

import domain.Point;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: sszheng
 * @Date: 2018/8/6 16:54
 */
public class FunctorChain {
    private List<Functor> filters = new ArrayList<Functor>();

    public FunctorChain addFunctor(Functor functor) {
        this.filters.add(functor);
        return this;
    }

    public void calc( List<Point> list) {
        Boolean flag ;
        do {
            flag = Boolean.FALSE;
            for(Functor functor: filters) {
                flag = flag || functor.calc(list);
            }
        } while (flag);
    }
}
